package com.ylbh.modules.toconfigure.controller;

import com.ylbh.common.utils.CommonResult;
import com.ylbh.common.utils.Ref;
import com.ylbh.modules.toconfigure.entity.ShoppingSettings;
import com.ylbh.modules.toconfigure.service.ShoppingSettingsService;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: czx
 * @date: 2019/08/06 09:55
 * 平台配置
 */
@RestController
@RequestMapping("setting")
public class ShoppingSettingsController {

    @Autowired
    private ShoppingSettingsService shoppingSettingsService;

    @ApiOperation("获取推广订单奖励")
    @GetMapping("getOrderAward")
    @RequiresPermissions("setting:getOrderAward")
    public CommonResult<ShoppingSettings> getOrderAward() {
        ShoppingSettings orderAward = shoppingSettingsService.getOrderAward();
        return Ref.ok(orderAward);
    }

    @ApiOperation("修改推广订单奖励")
    @PostMapping("modifyOrderAwardById")
    @RequiresPermissions("setting:modifyOrderAwardById")
    public CommonResult modifyOrderAwardById(@RequestBody ShoppingSettings shoppingSettings) {
        shoppingSettingsService.modifyOrderAwardById(shoppingSettings);
        return Ref.ok();
    }
}
